package com.tjs.lucky.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author TJS
 * @Description
 * @create 2023/7/14 21:11
 */
@Configuration
public class CommonConfig {

    @Value("${spring.redis.host}")
    private String redissonAddress;

    @Value("${spring.redis.port}")
    private String port;

    @Value("${spring.redis.password}")
    private String password;

    @Bean
    public RedissonClient redissonClient() {
        // 配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + redissonAddress + ":" + port)
                .setPassword(password);
        // 创建RedissonClient对象
        return Redisson.create(config);
    }
}
